<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
         contentType="text/html;charset=utf-8" %>
<%@ include file="/common/taglibs.jsp" %>
<head>
    <title>流水列表</title>
</head>
<body>
<div id="wrapper">
    <c:set var="left">bill</c:set>
    <%@ include file="/include/left/financial.jsp" %>

    <s:action name="bill!search" var="billList" executeResult="false">
        <s:param name="query.enabled">true</s:param>
        <s:param name="query.order">addTime</s:param>
        <s:param name="query.desc">true</s:param>
        <s:param name="query.pagesize">10</s:param>
        <c:if test="${param.startAddTime!=null && param.startAddTime!=''}">
            <s:param name="query.startAddTime">${param.startAddTime} 00:00:00</s:param>
        </c:if>
        <c:if test="${param.endAddTime!=null && param.endAddTime!=''}">
            <s:param name="query.endAddTime">${param.endAddTime} 23:59:59</s:param>
        </c:if>
    </s:action>

    <div id="page-wrapper" class="gray-bg">

        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>流水列表</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="${ctx}/productOrder/">运营管理</a>
                    </li>
                    <li>
                        <a>流水管理</a>
                    </li>
                    <li class="active">
                        <strong>流水列表</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2 m-add-new">
                <a href="${ctx}/bill/add" class="btn btn-info"><i class="glyphicon glyphicon-plus"></i> 线下退款添加</a>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight ecommerce">
            <form action="${ctx}/bill/" method="get" class="shaix">
                <div class="ibox-content m-b-sm border-bottom">
                    <div class="row">
                        <div class="col-sm-2">
                            <div class="form-group">
                                <label class="control-label" for="select">自定义时间</label>
                                <select id="select" class="form-control" name="timeType">
                                    <option value="3">自定义时间</option>
                                    <option value="0" <c:if test="${param.timeType==0}">selected</c:if>>今天</option>
                                    <option value="1" <c:if test="${param.timeType==1}">selected</c:if>>最近一周</option>
                                    <option value="2" <c:if test="${param.timeType==2}">selected</c:if>>最近一个月</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="form-group">
                                <label class="control-label" for="date_before">开始时间</label>
                                <input type="text" id="date_before" name="startAddTime" class="form-control"
                                       placeholder="开始时间" value="${param.startAddTime}">
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="form-group">
                                <label class="control-label" for="date_after">结束时间</label>
                                <input type="text" id="date_after" name="endAddTime" class="form-control"
                                       placeholder="结束时间" value="${param.startAddTime}">
                            </div>
                        </div>

                        <div class="col-sm-2">
                            <div class="form-group">
                                <label class="control-label" for="category">分类</label>
                                <c:set var="billCategories" value="<%= cn.org.eshow.common.ShopDataVar.billCategory.values() %>"/>
                                <select name="query.category" id="category" class="form-control">
                                    <option value="" >选择类型</option>
                                    <c:forEach var="billCategory" items="${billCategories}">
                                        <option value="${billCategory}"<c:if test="${query.category==billCategory}">selected</c:if> >${billCategory}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="col-sm-2">
                            <div class="form-group">
                                <label class="control-label" for="type">类型</label>
                                <c:set var="billTypes" value="<%= cn.org.eshow.common.ShopDataVar.billType.values() %>"/>
                                <select name="query.type" id="type" class="form-control">
                                    <option value="" >选择类型</option>
                                    <c:forEach var="billType" items="${billTypes}">
                                        <option value="${billType}"<c:if test="${query.type==billType}">selected</c:if> >${billType}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="col-sm-12">
                            <input type="submit" class="btn btn-sm btn-primary" value="查询"/>
                        </div>
                    </div>

                </div>
            </form>


            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox">
                        <div class="ibox-content">

                            <table class="footable table table-striped table-hover toggle-arrow-tiny default breakpoint footable-loaded"
                                   data-page-size="15">
                                <thead>
                                <tr>

                                    <th data-toggle="true"
                                        class="footable-visible footable-first-column footable-sortable">添加时间<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="phone" class="footable-visible footable-sortable">分类<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="all" class="footable-sortable">类型<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="phone" class="footable-visible footable-sortable">订单号(订单类型)<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="phone" class="footable-visible footable-sortable">收支金额<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="all" class="footable-sortable">用户<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="all" class="footable-sortable">备注<span
                                            class="footable-sort-indicator"></span></th>
                                    <th data-hide="all" class="footable-sortable">操作<span
                                            class="footable-sort-indicator"></span></th>

                                </tr>
                                </thead>
                                <tbody>

                                <s:iterator value="%{#billList.bills}" status="rowStatus"
                                            var="bill">
                                    <tr class="footable-even" style="">
                                        <td class="footable-visible">
                                            <s:date name="%{addTime}" format="yyyy-MM-dd HH:mm"></s:date>
                                        </td>
                                        <td class="footable-visible">${category}</td>
                                        <td class="footable-visible">${type}</td>
                                        <td class="footable-visible">${orderNo}(<c:if test="${orderType=='productOrder'}">普通订单</c:if><c:if test="${orderType=='additionalOrder'}">补单</c:if>)</td>
                                        <td class="footable-visible">
                                            <c:if test="${receive==0}">-${outlay}</c:if>
                                            <c:if test="${outlay==0}">+${receive}</c:if>
                                        </td>
                                        <c:if test="${user!=null}">
                                            <td class="footable-visible">${user.username}</td>
                                        </c:if>
                                        <c:if test="${user==null}">
                                            <td class="footable-visible">平台流水</td>
                                        </c:if>
                                        <td data-toggle="tooltip" data-placement="bottom"
                                            class="footable-visible footable-first-column">
                                            <span data-toggle="tooltip" data-placement="top"
                                                  title="${remark}"> ${util:preview(remark,true,10)} </span>
                                        </td>
                                        <td class="text-right footable-visible footable-last-column">
                                            <%-- 只能修改今天添加上去的 平台线下退款流水--%>
                                            <c:set var="todayStartTime"><%=DateUtil.getStartOfToday().getTime()%></c:set>
                                            <c:if test="${type=='平台线下退款' && addTime.time>=todayStartTime}">
                                                <div class="btn-group">
                                                    <button class="btn-info btn btn-xs" onclick="window.location='${ctx}/bill/edit/${id}'">编辑</button>
                                                    <button class="btn-danger btn btn-xs" onclick="deleteData('确定要删除吗','bill','${id}','${ctx}');">删除</button>
                                                </div>
                                            </c:if>

                                        </td>
                                    </tr>
                                </s:iterator>
                                </tbody>


                            </table>
                            <c:set var="href">query.category=${query.category}&query.type=${query.type}&timeType=${param.timeType}&startAddTime=${param.startAddTime}&endAddTime=${param.endAddTime}&</c:set>
                            <%@ include file="/common/page.jsp" %>
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <%@ include file="/common/footer.jsp" %>

    </div>

</div>

<%@ include file="/common/scripts.jsp" %>
<%@ include file="/common/script/cxcalendar.jsp" %>

</body>

